var app = getApp()
Page({

    /**
     * 页面的初始数据
     */
    data: {
        navTo: '',
        marginTop: '',
        name: '',
        modalName: '',
        selectedPerson: null,
        selectedNumber: null,
        whatCompany: '',
        v_value: '',
        curIndex: 0,
        curNav: 0,
        // peopleList: ['艾力', '喻总', '西尔扎提', '迪力木拉提', '小孔', '努尔夏西']
        riderCommentList: [{
            value: '艾力',
            selected: false,
            title: '艾力',
            number: 55555
        }, {
            value: '喻总',
            selected: false,
            title: '喻总',
            number: 55555
        }, {
            value: '西尔扎提',
            selected: false,
            title: '西尔扎提',
            number: 55555
        }, {
            value: '服务专业',
            selected: false,
            title: '服务专业',
            number: 55555

        }, {
            value: '迪力木拉提',
            selected: false,
            title: '迪力木拉提',
            number: 55555
        }, {
            value: '小孔',
            selected: false,
            title: '小孔',
            number: 55555
        }, {
            value: '努尔夏西',
            selected: false,
            title: '努尔夏西',
            number: 55555
        }],
        items: [{
                value: 'huanjing',
                name: '测试环境',
                id: 2,
                checked: 'true',

            }, {
                value: 'jiance',
                name: '检测',
                id: 0
            },
            {
                value: 'qihou',
                name: '气候论证',
                id: 1
            },


        ]
    },


    navTap(e) {
        let id = e.currentTarget.dataset.id;
        console.log(id);
        this.setData({
            curNav: id,
            curIndex: id
        })
    },
    radioChange(e) {
        let v = e.detail.value
        const items = this.data.items
        for (let i = 0, len = items.length; i < len; ++i) {
            items[i].checked = items[i].value === e.detail.value
        }

        this.setData({
            items,

        })
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        let that = this
        that.setData({
            marginTop: app.globalData.statusBarHeight + 'px',
            navTo: app.globalData.navHeight + 'px',
            name: options.name
        })

    },
    Gotback() {
        wx.navigateBack({
            delta: 1,
        })
    },
    getTextArea(e) {
        console.log(e.detail.value)
    },
    hideModal(e) {
        this.setData({
            modalName: null
        })
    },
    addTable(e) {
        this.setData({
            modalName: e.currentTarget.dataset.target
        })
    },
    // 挑选人员
    checkboxChange(e) {
        console.log('checkboxChange e:', e);
        let string = "riderCommentList[" + e.target.dataset.index + "].selected"
        console.log(string)
        this.setData({
            [string]: !this.data.riderCommentList[e.target.dataset.index].selected
        })
        let detailValue = this.data.riderCommentList.filter(it => it.selected).map(it => it.value)
        let numbers = this.data.riderCommentList.filter(it => it.selected).map(it => it.number)
        console.log('所有选中的值为：', detailValue, '选中number:', numbers)
        this.setData({
            selectedPerson: detailValue,
            selectedNumber: numbers
        })
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },
    // 获取是个气象局input value
    whatCompany(e) {
        // console.log(e.detail.value)
        this.setData({
            whatCompany: e.detail.value
        })
    },
    // 提交整个表
    submitBtn() {
        let selectedPerson = this.data.selectedPerson.join("、")
        let selectedNumber = this.data.selectedNumber.join("、")
        let str =
            `我们是${this.data.whatCompany}气象局行政执法人员${selectedPerson}，证件号码为${selectedNumber}，这是我们的执法证件(出示证件)。我们依法像你了解有关心情况，请配合。`

        console.log(str)
        // 这里在提交内容即可
    },
    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})